package com.zhentao.controller;

import com.zhentao.model.common.app.pojo.ApCar;
import com.zhentao.model.common.app.vo.ApCarVo;
import com.zhentao.model.common.buiness.dto.AddDto;
import com.zhentao.model.common.buiness.dto.CarDto;
import com.zhentao.model.common.dtos.ResponseResult;
import com.zhentao.service.ApCarService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author 86150
 */
@RestController
@RequestMapping("/apcar")
@Api(tags = "car",description = "用户购物车")

public class ApCarController {
    @Resource
    private ApCarService apCarService;
    @ApiOperation("用户端：购物车列表")
    @PostMapping("/carlist")
    public ResponseResult carlist(@RequestBody ApCarVo apCarVo){
        return apCarService.carList(apCarVo);
    }
    @ApiOperation("用户端：购物车添加")
    @PostMapping("caradd")
    public ResponseResult addcar(@RequestBody ApCar apCar){
        return apCarService.addCar(apCar);
    }
    @ApiOperation("用户端：购物车删除")

    @GetMapping("/delcar/{id}")
    public ResponseResult delete(@PathVariable("id") Integer id){
     return apCarService.deleteCar(id);
    }

    @PostMapping("carByOrder")
    public ResponseResult carByOrder(@RequestBody AddDto addDto){

        System.out.println(addDto);
        return apCarService.carByOrder(addDto);


    }
}
